package at.technikum_wien.embsys.aat.PriscillaCore.connection;

import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.InterruptedIOException;
import java.net.Socket;
import java.util.List;

import javax.xml.parsers.ParserConfigurationException;

import org.xml.sax.SAXException;

import at.technikum_wien.embsys.aat.PriscillaCore.component.EnoceanComponent;
import at.technikum_wien.embsys.aat.PriscillaCore.data.EnoceanRawData;
import at.technikum_wien.embsys.aat.PriscillaCore.enums.TeachInOptions;
import at.technikum_wien.embsys.aat.PriscillaCore.parsing.EnoceanComponentParser;

public class IPGatewayConnectionMonitor extends Thread {
	private Socket socket;
	private DataInputStream is;

	IPGatewayConnectionMonitor(Socket socket){
		super("EnoceanNet/IP receiver");
		this.socket = socket;

		setDaemon(true); // set Deamon Threat
	}
	

	
	/* (non-Javadoc)
	 * @see java.lang.Thread#run()
	 */
	public void run() {
		try {
			is = new DataInputStream(socket.getInputStream());
		} catch (IOException e) {
			e.printStackTrace();
		}
		System.out.println("CheckConnectionRunning");
	    while (true)
	    {
	        try {
				is.available();
			} catch (IOException e) {
				e.printStackTrace();
				System.out.println("1111");
			}
	        try {
				Thread.sleep(1000);
			} catch (InterruptedException e) {
				e.printStackTrace();
				System.out.println("2222");
			}
		}
	}
}
